import React, { useMemo } from "react";
// import { useSelector } from "react-redux";
import { Routes, Route, Navigate } from "react-router-dom";
import { useSelector } from "react-redux";
import "antd/dist/antd.css";
import * as echarts from 'echarts';


import Home from "./views/manage/Home";
import Manage from "./views/Manage";
import Login from "./views/Login";

function App() {
  const userInfo = useSelector((state) => state.userInfo);
  console.log('userInfo',userInfo);
  // ！！  对应的值为true
   const isLogin = useMemo(() =>{
   return !!userInfo.id
   } , [userInfo]);
  // useMemo 优化问题
  // const isLogin =()=>{
  //   !!userInfo
  // }
   console.log('isLogin',isLogin)
  return (
    // <Manage />
            <Routes>
            <Route path='/login' element={<Login />} />
            {
                isLogin ?
                <Route path='/manage/*' element={<Manage user={userInfo} />} />
                :
                null
            }
        //     <Route path="*" element={<Navigate to={isLogin ? '/home' : '/login'} />} />
          </Routes>
        // // isLogin ?
        // <Manage />
        // // :
        // // <Login />
  );
}
export default App;
